
/*    This file is part of the Managarm operating system.
 *   Copyright (C) 2007, 2008, 2009  Alexander van der Grinten
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>. */

package org.managarm.jmanacclib.generic;

public class GnProcInfo {

	public final GnProcedure codeObject;
	// one frame information struct for each frame
	public final GnFrameInfo[] frameInfos;
	
	public GnProcInfo(final GnMethod method,
			final GnProcedure code) {
		this.codeObject = code;
		
		// create frame information structs
		frameInfos = new GnFrameInfo[codeObject.frames.size()];
		if(method != null) {
			frameInfos[0] = new GnFrameInfo(codeObject.frames.get(0), true);
			for(int i = 1; i <= method.argumentCnt; i++)
				frameInfos[0].addArgument(i, true);
		}else{
			frameInfos[0] = new GnFrameInfo(codeObject.frames.get(0), false);
		}
		for(int i = 1; i < codeObject.frames.size(); i++)
			frameInfos[i] = new GnFrameInfo(codeObject.frames.get(i), false);

		// analyze the (direct) dependencies of the frames
		for(int i = 0; i < codeObject.frames.size(); i++)
			frameInfos[i].analyzeArguments();
	}
}
